<?php

/**
 * GlDiscount form base class.
 *
 * @method GlDiscount getObject() Returns the current form's model object
 *
 * @package    GREEN_LIGHT
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseGlDiscountForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'discount_id'       => new sfWidgetFormInputHidden(),
      'name'              => new sfWidgetFormTextarea(),
      'value'             => new sfWidgetFormInputText(),
      'quantity'          => new sfWidgetFormInputText(),
      'quantity_per_user' => new sfWidgetFormInputText(),
      'date_from'         => new sfWidgetFormDate(),
      'date_to'           => new sfWidgetFormDate(),
      'is_active'         => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'discount_id'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('discount_id')), 'empty_value' => $this->getObject()->get('discount_id'), 'required' => false)),
      'name'              => new sfValidatorString(array('required' => false)),
      'value'             => new sfValidatorInteger(array('required' => false)),
      'quantity'          => new sfValidatorInteger(array('required' => false)),
      'quantity_per_user' => new sfValidatorInteger(array('required' => false)),
      'date_from'         => new sfValidatorDate(array('required' => false)),
      'date_to'           => new sfValidatorDate(array('required' => false)),
      'is_active'         => new sfValidatorBoolean(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('gl_discount[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'GlDiscount';
  }

}
